package com.yzh.ios5;

import java.io.*;

/**
 * @author 于振晗
 * @title: DataInputStreamTest
 * @description: TODO 测试数据流
 * @date 2020年09月07日
 * @path com.yzh.ios5
 */
public class DataInputStreamTest {
    public static void main(String[] args) throws IOException {
        write();
        read();
    }

    public static void read() throws IOException {
        BufferedInputStream bis = new BufferedInputStream(new FileInputStream("d:/test4.txt"));
        DataInputStream dis = new DataInputStream(bis);
        System.out.println(dis.readInt());
        System.out.println(dis.readDouble());
        System.out.println(dis.readChar());
        System.out.println(dis.readBoolean());
        bis.close();

    }
    public static void write() throws IOException {
        BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream("d:/test4.txt"));
        DataOutputStream dos = new DataOutputStream(bos);
        dos.writeInt(1);
        dos.writeDouble(5.5);
        dos.writeChar('A');
        dos.writeBoolean(true);
        dos.close();
    }
}
